//
//  RBGoodsOrderVC.m
//  zhongzhenglu
//
//  Created by XL on 2022/8/12.
//

#import "RBGoodsOrderVC.h"
#import "RBDefine.h"
#import "UIView+RBAdd.h"
#import "UIScrollView+RBAdd.h"
#import <Masonry.h>
#import "RBThemeConfig.h"
#import <UIColor+YYAdd.h>
#import <UIView+YYAdd.h>
#import "RBPager.h"
#import "RanTool.h"
#import <UINavigationController+FDFullscreenPopGesture.h>
#import "RBGoodsOrderListVC.h"

@interface RBGoodsOrderVC ()

@property (nonatomic, strong) RBPagerView *pagerView;
@property (nonatomic, strong) NSMutableDictionary *vcsDicM;

@end

@implementation RBGoodsOrderVC

#pragma mark - Lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setup];
}

#pragma mark - Private

- (void)setup
{
    self.title = @"我的订单";
    self.view.backgroundColor = UIColor.whiteColor;
    self.pagerView.hidden = NO;
}

- (RBGoodsOrderListVC *)getVcAtIndex: (NSInteger)index
{
    RBGoodsOrderListVC *vc = self.vcsDicM[@(index)];
    if (!vc)
    {
        vc = RBGoodsOrderListVC.new;
        if (index == 5) {
            vc.status = 6;
        } else {
            vc.status = index - 1;
        }
        [self addChildViewController:vc];
        self.vcsDicM[@(index)] = vc;
    }
    return vc;
}


#pragma mark - Network

#pragma mark - Event

#pragma mark - Setter

#pragma mark - Getter

- (RBPagerView *)pagerView
{
    if (!_pagerView)
    {
        self.pagerView = ({
            RBPagerView *view = RBPagerView.new;
            [self.view addSubview:view];
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.edges.mas_equalTo(0);
            }];
            
            __weak typeof(self) weakSelf = self;
            view.getVcBlock = ^UIViewController * _Nonnull(NSInteger index) {
                return [weakSelf getVcAtIndex:index];
            };
            CGFloat headerH = Zoom(43);
            [view configWithHeaderStickTop:0 headerBottom:0 headerHeight:headerH floatViewHeight:headerH];
            [view setupWithModel:({
                RBPagerHeaderModel *model = RBPagerHeaderModel.new;
                model.titles = @[@"全部", @"待付款", @"待发货", @"待收货", @"待评价", @"已完成"];
                model.titleFontName = [UIFont systemFontOfSize:1 weight:UIFontWeightMedium].fontName;
                model.selectedIndex = self.index;
                model.titleSizeForNormalState = Zoom(13);
                model.titleSizeForSelectedState = Zoom(13);
                model.titleColorForNormalState = [RBThemeConfig textBlackColor];
                model.titleColorForSelectedState = [RBThemeConfig textBlackColor];
                model.buttonWidthStyle = RBPagerButtonWidthConstValue;
                model.headerButtonWidth = kRBMainScreenWidth/model.titles.count;
                model.showSeperator = NO;
                model.bottomLineColor = [UIColor colorWithHexString:@"#3974EC"];
                model.bottomLineWidth = Zoom(26);
                model.bottomLineHeight = Zoom(2);
                model.bottomLineWidthStyle = RBPagerBottomLineWidthConstValue;
                model;
            })];
            view.floatView.backgroundColor = UIColor.whiteColor;
            view;
        });
    }
    return _pagerView;
}

- (NSMutableDictionary *)vcsDicM
{
    if (!_vcsDicM)
    {
        self.vcsDicM = NSMutableDictionary.dictionary;
    }
    return _vcsDicM;
}

@end
